import pandas as pd
from common.recordlog import logs
import traceback

def read_csv(filepath,col_name):
    """
    :param filepath: csv目录
    :param col_name: 取值的列名
    :return:
    """
    try:
        df=pd.read_csv(filepath,encoding="GBK")
        # 转为列表
        data=df[col_name].tolist()
        return data
    except Exception:
        # traceback.format_exc() 可以捕获最近一次发生的异常的详细堆栈跟踪信息
        # str：转为字符串形式
        logs.error(str(traceback.format_exc()))